//
// Created by 谢哲 on 2021/5/15.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ull = unsigned long long;

int main() {
    ull N, M;
    cin >> N >> M;
    vector<ull> vdata(N);

    for (auto &p: vdata) cin >> p;

    ull l = 0, r = *max_element(vdata.begin(), vdata.end());
    ull right_ans = 0;
    while (l<=r) {
        auto mid = (l + r) >> 1ull;
        ull res = 0;
        for (ull i=0; i<N; ++i) {
            res += vdata[i] - min(vdata[i], mid);
        }
        if (res >= M) {
            right_ans = mid;
            l = mid + 1;
        }
        else {
            r = mid - 1;
        }
    }

    cout << right_ans;

    return 0;
}
